package com.zhuanzhuan.hero.user.util;

import com.zhuanzhuan.hero.user.enums.ExceptionMsgEnum;
import com.zhuanzhuan.hero.user.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName Assert
 * @Description
 * @Author hanjunjun
 * @Date 2024/6/27 19:39
 */
public class Assert {

    public static void notNull(Object obj, ExceptionMsgEnum exceptionMsgEnum) {
        if (null == obj) {
            throw new BusinessException(exceptionMsgEnum);
        }
    }

    public static void notNull(Object obj) {
        if (null == obj) {
            throw new BusinessException(ExceptionMsgEnum.PARAM_ERROR);
        }
    }

    public static void notBlank(String obj, ExceptionMsgEnum exceptionMsgEnum) {
        if (StringUtils.isBlank(obj)) {
            throw new BusinessException(exceptionMsgEnum);
        }
    }

    public static void isTrue(boolean obj, ExceptionMsgEnum exceptionMsgEnum) {
        if (!obj) {
            throw new BusinessException(exceptionMsgEnum);
        }
    }
}
